<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;


class AnswerController extends CommonController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $res)
    {
        //后台管理者回复进这里
        dd($res);
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
        $name = $_GET['name'];
        dd();
        //又可以搜人，又可以搜书名，那就两个表一起搜，然后整合到一个数组，接着输出；
        $data1 = \DB::table('user')->where('userName','like','%'.$name.'%')->get();
        $data2 = \DB::table('goodsdetail')->where('bookName','like','%'.$name.'%')->get();
        return "后面还没写呢,2016年8月22日22:05:53：请使用多表联查做搜索";
        // return view('admin.comment.create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //后台管理者回复进这里
        $data = $_POST;
        unset($data['_token']);
        $data['ctime'] = time();
        $m = \DB::table('reply')->insertGetId($data);
        if($m>0){
            return redirect('admin/ask');
        }else{
            return back().with('err',"没有回复成功");
        }
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {   
        // 
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
       
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
        // dd($id);
        $m = \DB::table('reply')->where('id',$id)->delete();
        return back();
        if($m){
            return view('admin.aa.info',['info'=>'删掉了！！']);
        }else{
            return view('admin.aa.info',['info'=>'没有删掉！！']);
        }
    }
}
